//---------------------------------------------------------------------------- // File: UP3D.h // Version: 2.0 // Class: Universal Pipeline 3D // Type: 3D Object // Author: Ken Anderson // Date: 3/19/04 // OS dependant: NA // Desc: The universal pipeline 3d is a link list that acts like a pipeline supplying // either 3d renderer with vertices, matricies, render states, lighting // objects and so forth. // // Notes: A class was not used here to keep the overhead down as much as // possible. In addition, multiple pipelines are not required, thus // one set of global static variables are needed rather than defining // a class for multiple pipelines. // // IMPORTANT WARNING: // -Note: Always initialize the pipeline before using it as well as cleaning // it up once the 3d management system has completed using it. Failure // to initialize this system will return an error code. See below. // Failure to clean up will leave memory hanging in the system. // // -NOTE2: The pipeline uses what is referred to as a reverse pipeline, please // see notes in the R-Pipelin.txt file. // // Version 2.0 -- Updated 10/11/04 to protect against a tail & head bug that would // leave these special pointers invalid and not set them null. // // Required headers: // 1) C3DTypes.h -- Contains structures, and enumations the class relies on. // //---------------------------------------------------------------------------- //Prevent redefinition #ifndef __UP3D__ #define __UP3D__ #include "C3DTypes.h" /////////////////////////////////// // ENUMS // /////////////////////////////////// //Types used for the universal packets being sent throught //the rendering pipeline. typedef enum UNIVERSAL_PACKET_TYPE { UPT_UNKNOWN, UPT_VERTEX, UPT_RENDERSTATE, UPT_TSS, UPT_MATRIX, UPT_LIGHT, UPT_MATERIAL, UPT_TEXTURE } UPT; ///////////////////////////////////////////////////////////////////////// // UNIVERSAL PACKET // ///////////////////////////////////////////////////////////////////////// //The special packet is used to hold an array of void pointers with a //field that specifies the amount of pointers. typedef struct SPECIAL_BUFFER_PACKET { void** vhBuffers; Dword dwBufferNum; } SPECIALBP, *PSPECIALBP; //The universal packet is designed to be the main element used in the //rendering pipeline allowing blocks & packets to be used by the renderer //in the order specified by the programmer. typedef struct UNIVERSAL_PACKET { void* pPacket; void* pHead; void* pTail; UPT type; UNIVERSAL_PACKET* Next; UNIVERSAL_PACKET* Prev; } SC3DUniversal, *PSC3DUniversal, **HSC3DUniversal; //Pipeline pointers. static PSC3DUniversal UP3Dm_pPHead, UP3Dm_pPTail, UP3Dm_pPCurr; static bool UP3Dm_bInited = false; static bool UP3Dm_bEmpty; /////////////////////////////////// // FUNCTIONS // /////////////////////////////////// //Init. void UP3D_Init(); void UP3D_Cleanup(); //void UP3D_DeleteTypes(SC3DUniversal* pDel); C3DERR UP3D_EmptyPipe(); C3DERR UP3D_InitChk(); //Create New Element PSC3DUniversal UP3D_CreateTopUniversalElement(void* pPacket=NULL, UPT type=UPT_UNKNOWN); PSC3DUniversal UP3D_CreateCurrentUniversalElement(void* pPacket=NULL, UPT type=UPT_UNKNOWN); PSC3DUniversal UP3D_CreateUniversalElement(void* pPacket, UPT type, HSC3DUniversal pLoc); //Delete element. C3DERR UP3D_DeleteTopUniversalElement(); C3DERR UP3D_DeleteCurrentUniversalElement(); C3DERR UP3D_DeleteUniversalElement(PSC3DUniversal pLoc); //Set the details. C3DERR UP3D_SetCurrentPacket(void* pPacket, UPT type); C3DERR UP3D_SetCurrentHead(void* pHead); C3DERR UP3D_SetCurrentTail(void* pTail); //Current pointer settings. C3DERR UP3D_SetCurrentToHead(); C3DERR UP3D_SetCurrentToTail(); C3DERR UP3D_SetCurrent(PSC3DUniversal pCurr); //Set details of specified packet C3DERR UP3D_SetPacket(PSC3DUniversal pCurr, void* pPacket, UPT type); C3DERR UP3D_SetPacketOnly(PSC3DUniversal pCurr, void* pPacket); C3DERR UP3D_SetHead(PSC3DUniversal pCurr, void* pHead); C3DERR UP3D_SetTail(PSC3DUniversal pCurr, void* pTail); //Return Current details. void* UP3D_ReturnCurrentPacket(); UPT UP3D_ReturnCurrentType(); void* UP3D_ReturnCurrentHead(); void* UP3D_ReturnCurrentTail(); PSC3DUniversal UP3D_ReturnPipelineHead(); PSC3DUniversal UP3D_ReturnPipelineTail(); PSC3DUniversal UP3D_ReturnPipelineCurr(); #endif